<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{$title}</title>
<include file='web/Common:source'/>
<style>
div.layui-layer-shade{background-color:rgba(255,255,255,0) !important;}
div.layui-layer-rim{border:none; box-shadow:3px 5px 6px #dadada,-3px -1px 6px #dadada;}
div.layui-layer-title{background-color:#e2e5e8;}
</style>
</head>
<body ng-app="myApp" ng-controller="myAppControl">
	{{username}}
</body>
<script type="text/javascript">
var myApp = angular.module("myApp",[]);
var getUrl = "{:U('Stock/angularGet')}";
var postUrl = "{:U('Stock/angularPost')}";
$.post(postUrl,{name:'132456789'},function(res){
	console.log(res);
});
myApp.controller("myAppControl",function($scope,$http){
	$scope.username = "张三";
	// get 携参数访问
	ajaxGet(getUrl,{name:'张三'},function(res){
		console.log(res );
	});
	function ajaxGet(url,data,fun){
	    $http.get(url,{params:data}).then(function(res){
	        fun(res);
	    });
	};
	// post 携带参数访问
	$http({  
	    method:'post',  
	    url:postUrl,  
	    data:{name:"aaa",id:1,age:20}  
	}).success(function(req){  
	    console.log(req);  
	});
	$http({  
		method:'post',  
		url:postUrl,  
		data:{name:"aaa",id:1,age:20},  
		headers:{'Content-Type': 'application/x-www-form-urlencoded'},  
		transformRequest: function(obj) {  
			var str = [];  
			for(var p in obj){  
				str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));  
			}  
			return str.join("&");  
		}  
	}).success(function(req){  
		console.log(req);  
	});
});
</script>
</html>

